

'use strict'

const ExtraInfo = require('../ExtraInfo')
const {guid} = require('../utils')

module.exports = function(handler){
    let {impl, Model, Model_name, wrapper, extra_map} = handler

    impl(Model, '_init', function(){
        this.__guid = guid() // boy唯一的隐藏变量
        let extra_info = new ExtraInfo(this.__guid, Model_name)
        extra_info.setWrapper(wrapper)
        extra_map[this.__guid] = extra_info
        return this
    })

    impl(Model, '$type', function(){
        return 'BOY_MODEL'
    })

    impl(Model, '$extra', function(){
        let extra_info = extra_map[this.$guid()]
        return extra_info
    })

    impl(Model, '_setName', function(name){
        this.$extra().setName(name)
    })

    impl(Model, '_setMount', function(mount){
        this.$extra().setMount(mount)
    })

    impl(Model, '_setPoint', function(point){
        this.$extra().setPoint(point)
    })

    impl(Model, '$guid', function(){
        return this.__guid
    })
}